package flc.ast.adapter;

import android.graphics.Color;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.irremote.lib.base.Category;
import com.stark.irremote.lib.base.bean.IrRemote;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class RemoteAdapter extends StkProviderMultiAdapter<IrRemote> {

    public RemoteAdapter() {
        addItemProvider(new StkSingleSpanProvider(165));
        addItemProvider(new RemoteProvider());
    }

    private boolean isEdit = false;
    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private class RemoteProvider extends BaseItemProvider<IrRemote> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_remote;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, IrRemote bean) {
            if (bean.categoryId == Category.AIR_CONDITIONER.getId()) {
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.akongt);
            } else if (bean.categoryId == Category.TV.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.adianshi);
            }else if (bean.categoryId == Category.LIGHT.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.adeng);
            }else if (bean.categoryId == Category.FAN.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.afenshan);
            }else if (bean.categoryId == Category.AUDIO.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.ayinxiang);
            }else if (bean.categoryId == Category.CLEANING_ROBOT.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.asaodijiqir);
            }else if (bean.categoryId == Category.AIR_CLEANER.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.akongqijinhuaq);
            }else if (bean.categoryId == Category.BSTB.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.ajidinhe);
            }else if (bean.categoryId == Category.PROJECTOR.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.atouyinyi);
            }else if (bean.categoryId == Category.IPTV.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.aiptv);
            }else if (bean.categoryId == Category.DVD.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.advd);
            }else if (bean.categoryId == Category.NET_BOX.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.awangluohezi);
            }else if (bean.categoryId == Category.DYSON.getId()){
                baseViewHolder.setImageResource(R.id.ivRemoteItemLog, R.drawable.adyson);
            }
            baseViewHolder.setText(R.id.tvRemoteItemName, bean.name);
            baseViewHolder.setText(R.id.tvRemoteItemCategory,bean.categoryName);
            if (isEdit) {
                baseViewHolder.getView(R.id.ivRemoteItemDelete).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivRemoteItemDelete).setVisibility(View.GONE);
            }
        }
    }

}
